package com.yun.datastructure.graph.domain;

import java.util.List;
import java.util.Objects;

public class Vertex {
    public String name;
    public List<Edge> edges;

    public boolean visited;
    public int inDegree;
    /**
     * 状态 0 未访问过
     */
    public int status;
    /**
     * 距离
     */
    public int dist = INF;
    static final Integer INF = Integer.MAX_VALUE;

    public Vertex prev = null;

    public Vertex(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Vertex vertex = (Vertex) o;
        return Objects.equals(name, vertex.name);
    }

    @Override
    public int hashCode() {
        return name != null ? name.hashCode() : 0;
    }
}
